Refactored router to use route dispatcher, simplified logic in tests, created base controller