Fixed test code and model code to pass all tests.