Refactored login method used throughout unit-tests.