Test: fix unit tests to work with middleware (#3468)

@nschonni this'll take care of the unit tests failures you're getting with your middleware PR.