DRY'ing, formatting and testing query_string method