restructure the testing code, and fix an issue found in testing.