using assertRaises instead of try-except block in the unit test