doctest and queries are queries, num_queries is len(queries)