RF: move script running code into own module

Refactor code to run scripts into own module.  In fact I'm using a version I
refactored for another project, to make it easier to use across projects, but
I think this makes the code easier to read and support.