Ah i see! thats quite helpful that you get a similar error with AD groups – i did think it was something to do with that, so i put a couple of 'sleeps' between functions so to give it a chance to actually register the groups, however it didn't make any different and i dismissed it.
I will go back to that and look at it again, perhaps with the AD group already created and see how it behaves.
thanks!