shdict: improved the error handling a bit and also increased the tests' code coverage.