Fix sign out bug and tests