Use assertRaises instead of try/except block

Signed-off-by: Martin Koistinen <mkoistinen@gmail.com>