Refactor authentication to make it adaptable.
Update README with instructions for running tests.