handle unicode better and fix bugs with tests