add tests for file write attempt and non-zero return code