Handle two more error conditions correctly

* Handle two more error conditions correctly

* fixed test case
2 files changed