Move some helpers from test.js to utils.js

Depends on #643.
Moved these three test helpers to `utils.js`.