login_exists function and corresponding unit tests