Mainly to verify groups visibility this new callback has been created.
Note this was originally 3 commits but for amending purposes they have
been squashed.
When different ID's are set for each sequence a number
of unit test failures appear. They have been corrected
to allow unit tests to pass with the new generator in place.
instance is has been used instead of cmid. This works as all id's are 1
in most cases, but not always.
accesslib_clear_all_caches_for_unit_testing was updated to clear the
$USER->access cache which would fail test when the wrong user's data was used.