Cleaned up and improved the test code.