Add tests for middleware.