Make middleware test sensible

The database queries have to be executed in series for the test to make
any sense.