Fix and add tests

Related to rfc3986 / pretty modes
Support empty string replacement and add test