Added Unit tests for AuthenticationController. Some Refactoring towards better testable code