Refactor loadTest into middleware