Refactoring AbstractQuery module and specs