Minor refactor of QueryTest to make it more reusable later. Adds table and column aliasing.