Improve query string handling. 

* Add objectToQuery and queryToObject.
* Start replacing fragile URL query string manipulation with those functions.
* Fix specs that incorrectly depended on exact URL string equality, and other spec cleanup.

Fixes #2165
Same comment as above.  I guess I'm okay with using `defaultValue` in these cases since you are already inside of a constructor function and therefore it's unlikely to ever be a bottleneck.