Refact: move code
Add test case for chinese encode