Fixes for test case generation driver, some refactoring