Added new tests,  refactored model code & example code.