fix a bug and test on macos