shdict: improved the error handling a bit and also added more (passing) tests.