Backport of #9225

fix in displayNamesInGroup: when specified limit N, we did complex search only in the first N users

change logic in displayNamesInGroup and add some unit tests

add more logic in displayNamesInGroup for big user bases

1. remove sizeof($filteredUsers) > 0 as condition
2. use count instead of sizeof. Latter is an alias to first one, practically we stick to count everywhere. Having it consistent helps with readability.
3. move whitespace so we have $groupUsers[] = $filteredUser; instead of $groupUsers []= $filteredUser;