Prevent /switch/ from crashing if not logged in

This is also relevant to the tests which I'm refactoring.