Clean up module test code
Partial rewrite of the model