PermissionsTestAll: refactor code.

This is an initial refactoring of @bramalingam's code. Tests still pass and hopefully the code is more readable.
Performed changes (among others):
- remove confusing var names,
- use camel-case,
- remove iterator use for map entries,
- use enhanced for loop,
- use maps to reduce the number of vars.