Add login and logout functionality to the worker

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.