Better warning message for orphan instances (Ticket #9178)

Including a test case.