Middleware unit tests