Fix tests, and use flattened title field for query construction