fix bugs in preprocess; now all tests in test dir passed