test case fix and fixes for found issues.