Improve test coverage and fix some model manager bugs