Fixed potential defined primary key bug, adding a bunch of tests for scoped relationships