Improve test coverage.

Test for some error cases by using the operating system mocks.