Fixed bug when creating URI for parent

The previous code was trying to modify a URI object, this is not
possible. Now a URI.Builder is used.