def user_exists(ssh_fn, name):
    """Test is a user exists.

    The ssh_fn is a function that takes a command and runs it on the remote
    system.  It requires the the ssh_fn raises an exception if the command
    fails.

    :param ssh_fn: a ssh_fn that can run commands on the unit.
    :type ssh_fn: Callable[[str], str]
    :param name: the name of the user to test if exists.
    :type name: str
    :returns: True if the user exists
    :rtype: bool
    """
    cmd = ["grep", "-c", "^{name}:".format(name=name), "/etc/passwd"]
    try:
        ssh_fn(cmd)
    except Exception:
        return False
    return True