Refactored queryj-debugging. Now some tests are failing