Modified the query manager to support testing