added tests.py and prepared for distutils.
merge with upstream