Fixed the model methods and add model tests