fixes according to review

raise on unrecoverable error
fix handling empty output
stub external commands