Added some model tests along with a few bug fixes