Replace try...except with assertRaises

Even the exception was not raised, try...except... still can pass the
test cases. So change to assertRaises.

Change-Id: Idec096d66fe8019cfa009dfa12e36bd4827485ad
Fixed incorrect indentation in the tests

Change-Id: I8900ac8542a9a0fd3ea41a8031eb66e79cefecd6
Merge "Fixed incorrect indentation in the tests"
Merge "Replace try...except with assertRaises"