Fixed getInstanceUrl() method. Added more tests.

The getInstanceUrl() returned a domain name if it was saved in the shared properies instead of an actual url.
That caused logging errors.