Add tests for dispatchermiddleware