fixes getDomainNameByResource() to not throw NullPointerException for non-existent resource references; adds test class