Refactor tests into test.js