Rewrite the `test` library to CommonJS style.

- rewrite all code under test/src to new CommonJS style
- update formating of the majority of the code (mostly whitespace)
- use `require()`s instead of namespaced references in tests
- also update the `viewhandler` tests to use `require()`s