added tests for middleware.py