Added test cases for Model and bugfixed alot.