improvements to library and tests