(Maint) Ensure tests are hitting the right ascpect

The previous tests were not very careful about making sure that they
were going to be going down the right branches to test the path that
they wanted. This makes some of the branch selection more explicit so
make the tests a bit more robust to change.
(#9862) Promote user/group logic to first class

Some core logic of the setting, which is how to manage the user and
group, was hidden inside obtuse if conditions. This tries to make it
clearer what is happening, at the expense of being longer, by promoting
the different values available for owner and group to classes that can
contain the logic for how to deal with that particular value.