@toolness mentioned in another project that without this comment, he would have found this code highly suspicious and recommended tests. I'm not 100% sure what to test though. See below for a basic middleware test.