refactor tests.js