fix StringIO/BytesIO usage in tests