I have a hunch that the GetObjectArmySlotCreature() function was mainly created to get the ID from a slot, rather than the number of units, and returns the total number of creature data.
Added 19 minutes later
Or maybe sleep() is not enough, which is why the number of creatures manages to be counted twice.