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 caffeine module & add a framework for testing it (no tests yet, though). see #23