Refactor routes, tests