Fixed addToDictionary encoding and fixed tests

- Fixes #57