added few tests, fixed encoding consistency