implement library and tests