Add test and fix some encode error.

puts() allow unicode string(encode to sys.__stdout__.encoding).
real_command now encode by env.host_encoding.