Improve forbidden checks

New functions were created to check 'allowed' access because the previous design
was checking after changes were possibly made.

Changed the unit test to use an already created user to simulate the original
error that was reported.

Change-Id: I9f7e56a5afd9624070fffef6672ef88cd549f210
Closes-Bug: #1174451
Fix indentation errors found by Pep8 1.4.6+

As a preparation in order to switch to a newer
Pep8 version in the future, fix the indentation errors
that are missed by Pep8 1.4.5 due to bugs.

Change-Id: I19af0bdc9c3c9681a2bf60eb6d86f45c4fb11bc6
Closes-Bug: #1267994
Merge "Fix indentation errors found by Pep8 1.4.6+"
Merge "Improve forbidden checks"