Refactor test.js