SI-5954 Makes the check for companion more discriminating.

My previous attempt was finding companions for things that it shouldn't have
been. This fix allows the entire library to compile clean and the
test still passes. Let's see what the kitteh says.