fix preprocessor unit tests

also make preprocessor code simpler and clearer