Add TryCatch() and test. Fix librt not found problem on Mac OS.