Fixed incorrect escaping in urlencoder
Processed review comments:

- ensure that the vars used in '-n' tests are always quoted;
- when checking result codes, be sure that no builtin are accidentally
  used to mask the real result code.
Added todo for debug logging.