added some tests; added urlencode and buildQuery