Added a test for queries helper and cleaned up a bit.