Moved some of run_program into util.py as a helper.