Fixed some issues with executeQuery and added more robust tests