Refactor into routes, fix the rest of tests