Refactored code to log in as a user into a helper module so that it can be shared between test cases.