Test for runQuery(), misc fixes