added tests for middleware stack