Refactor routes
Add tests