fixed python 2.6 issue,refactored generate_or_test