fix optimization bug in test generator