TestCase fixing and code cleanup.