fix signature generation

In canonical_string, query string must
be lexicographically sorted by query name.
This patch enables to work it correctly,
and adds a unit test for checking it.