Add test to see if specified gid is free

The errormessage uf you specified a GID that was already taken was not really helping for debugging, and the lack of this test caused logentries ('groupadd' was called anyway, which errored).
Merge pull request #5950 from Mrten/develop

Add test to group state to see if specified gid is free