fix issues uncovered when testing a basic query