Added tests for preprocessor, fixed several bugs