added tests for routes and refactored