Query test & fixes