Fix query count, imports
Fix tests