loginlogout function and tests