Add skeleton of TestBasicAuthMiddleware

* Fill in the names of all the tests and add helper
  methods.
* Clean up some dodgy imports/installed apps to avoid
  errors and tidy up the code.
* Change HTTPResponse(mimetype='text/plain') to use
  content_type instead of mimetype due to a deprecation
  warning.