Fix model and added tests