Move queryExceptionTest to ApiTestBase

This makes sense as all api queries can throw
these exceptions and the format of the check
is always the same
Change-Id: I476bfed19f8aadb48ff8ca2de192bc2d5410a21d