Refactored middleware and qunit files