fixed the test and refactored sso code