Added a bunch of tests for permissions, and made the tests pass.