query functions now working - see tests.