Tidy up api tests involving exceptions

Change-Id: Ic0e5457f7774cfbd9e01f1f692a33eb4d101c1be
Merge "Tidy up api tests involving exceptions"