Write tests for router and middleware