Move helpers into their own lib and add a test

This will probably fail on Travis as CKAN will now need to be installed.