Port the "test" lib to CommonJS style

This ports the while `test` lib to CommonJS style.