Improve reading of json from Gerrit API

The PR improves the way Gerrit API result json is queried so that
the test is more robust.

In addition, a potentially failing and unneccessary "visit()" call
was removed.

Lastly, the use of ProcessBuilder was re-worked to improve debugging
for failed command executions.
obj definition (JSONObject) could be moved to below try block, as it also does not need null initialization.