Fix unescaping of wildcards.

This commit fixes failing tests for unescaping wildcards. The implementation may not be optimal and could require some fine tuning.