fix query string parameter parsing

pull out functions for parsing query string and headers