A testing mock or other suggestions for adding UT's would be useful. Possibly adding an exec mock that could allow simulating a test program and returning different error codes and console output.
Maybe adding a simple mock program or shell script to provide the different error codes and output would work.