Fix bug in token uniqueness check