def _test(transformation, word1, word2):
    """Tries transforming word1 and word2 with the given transform function.
    
    It tries swapping the words if the transformation fails.
    This function returnsthe transformed words or false if
    the transformation failed both ways."""
    result = transformation(word1, word2)
    if not result:
        result = transformation(word2, word1)
        if result:
            return (result[1], result[0])
    return result