More tests for distribution.py
Add tests for sampling.
Use six.StringIO.
Move dit installation out of 'script' section for TravisCI.