Fixed parsing of service URLs:

- if the service URL contains a literal IPv6 address, the parsing
  could fail since this routine assumes that only the port is
  prefixed with a colon;
- added a couple of unit tests to verify the behavior of the fix.