Refactored routerUtils.js to pass tests, added some comments