Better handling of encoding errors on HashKey and Uri
Added test
Fixed tests