Address review comments by logging errors and catching them in tests and updating the hash at the end of successful writes only.