optgroup: add check for optgroup bit numbers being within range