Test locale settings and refactor tests
Test unicode and fix problems with writing unicode