Add login functionality, refactor functional tests. Passing test suite