Cleanup, and test for the new login() method

BMS-84

Reviewer: Daniel Villafuerte