added test cases and tidied up the parseQueryString helper function