add tests for middleware, update docs a bit