Use assertRaises instead of try/except blocks for unit tests