Converted middleware tests to use RequestFactory.

I probably would have done the quoting manually, but if you prefer using a function, I think we should use `from django.utils.six.moves.urllib.parse import quote_plus` as there aren't any unicode characters in this string and I think our custom version of `urlquote_plus()` is something we can drop when dropping Python 2 compatibility.