Fix bug + tests for single sign on.