Raise URI::InvalidURIError if wrong uri.

Until we implement our own parser, raise URI::InvalidURIError  when gid is incorrect
Nix the newline, indent the two private methods.