add unit tests for preview lib to make @DeepDiver1975 happy
some minor improvements to preview lib