Fix middleware tests