Add login functionality to the worker

Moved from PR 68 to remove signout functionality from PR, and addressed review comments.

The first 4 commits were paired by @n1k0, @fqueze and @Standard8

The rest of commits were by @Standard8 with a little input from @dmose. I suggest @fqueze reviews these commits.

The latest commits change the frontend tests to mock the necessary parts alongside the work by using sinon.js, and are now unit tests, not dependent on the node server or the sidebar.