unify all utility functions on utils.js
fix those files for testing