Fixing issues with query string building, adding better tests