Move helpers into lib for use in go cli

Signed off by MikeG