Fix pep8 and flake8 warnings and clean up code in dockutils/run_helper.py

 - Fixed pep8 warnings
 - Fixed flake8 warnings
 - Minor refactoring