Create unit tests using http://code.google.com/p/shunit2. Must refactor using tdd to design enhancement