Some functional fixes, more tests.

Added the proxyquire dependency to mock require calls, and moved some of
the form parsing code around. Added various tests, and caught an issue
with the cookie parser that resulted from a typo (and from stopping
testing midway through!).

New technical debt in the form of a couple of icky bits of definition in
the setup.js now I've moved from returning objects from the modules,
plus some horrible syntax still in the tests.