Refactoring.  Addition of login management and test cases