Progress with tests
Fix middleware tests