Seems like subprocess and friends (Popen, communicate) are not so easy to mock cleanly. Therefore, start from scratch and carefully write test by test, until (at least) the old test coverage has been restored.
Add tests for the utility functions and fix a few embarrassing bugs in the process.