Add some units tests for the model package and fix some bugs as a result
Fixes to tests coverage