Conversion to a namespaced library

Updated script so it can be used standalone or sourced as a library.
Added library test script.
Updated README