Fix user login/logout api and related tests.