Unit test for 417/408

Hi Rob,

I've exposed bug 417 (and possibly 408) where the discriminator should be in the join phrase. I've also implemented a solution that I have not included here. I'll post the patch in the group. I'm not confident the solution is proper.