The rule works on how the word is pronounced, not just on the first letter. So 'universal' and 'university' is 'a', as those two words sound start by sounding like like 'yoo', not 'un'.
Similarly, 'an' hour, as the 'h' is silent and is pronounced 'our'.