Make use of StringIO in tests Python 3 compatible