fixed relationships and added tests