Got a unit test framework working, wrote some unit tests and refactored code into a more consistant javascript style.