Refactored router and router tests