Some clean-up and refactoring
Convert Brian's test harness into a JUnit test