improve uri normalization and add unit tests