The comparison was wrong, therefore the code was adding the user to the tenant when it was already there. This raised an exception.Conflict. Also added a unittest for this case.
Cherry picked from 029d2ff7 and 55e50022