Add tests for setMiddleware"