validate.py and first test

validate.py comes from simplejson's tools.py,
under the MIT license.