Add test for middleware