Prevent duplicate users from being created

i.e. check for an existing type+foreignId
Add preliminary test for changing documents
Fix document:destroy test