character encode correction and fix test