This fixes most of the authorization tests on the perms branch

Also fixes saving of related objects.