Fix URI building and failure cases

This update uses the normalize_uri method for building
URIs. Additionally, failure cases have been modified
for a less generic version.