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.