improved gen_test, still not finished