Add profile middleware

Also introduced mocha (js test library) and sinon.js (spies, mochs,
stubs)
Add end-to-end test to profile middleware

Using zombie.js
Refactor profile middleware to not use deprecated APIs
Move helper methods to the end of the scope
Extract app and browser setup