Add tests for middlewares