Refactoring and continuing work on tests to support automated reloading with correct middlewares