Refactor some methods, add test for string escapes