Fixes up some minor bugs with the relationships module.  Also adds tests.