add test case for request
rewrite request/response middleware
fix middleware tests