Revert "Revert "middleware tests""

This reverts commit b3ba60455365673d418dad99c5ce59aca0a2e1f5.