refactored query string parsing and tests