Refactor tests to stop sharing global models between different test suites and use local per-app model registry instead. Also clean up all test code to use `const` and `let` instead of `var`.