Started login method.

Changed structure of previous code and resolved test cases