fixed special character escaping and added unit tests