Add testing and other fixes.

- Refactor config loading in app init to work with testing.
- Refactor views.
- Update models.