TestCase Fixing and code clean up