Working rspec tests for intellectual objects, refactored set_permissions code