Fixed some issues with the PermissionSet support.

Also added some basic tests for the security sandbox.