Remove usage of assert_in for py26 compatibility
Use error.args[0] instead of deprecated .message
Import StringIO from io if on py3
Add better Python 3 support