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
Merge pull request #780 from janhancic/develop-port-br-test-to-commonjs

Port the "test" lib to CommonJS style