Move utility functions from tests to util.js