lib-ification and seprating test script from utility functions