Fix erroneous order-dependent tests in trie code

Fixes #270. See #362 (awaiting confirmation that this fix is correct).
Merge pull request #363 from ElBrogrammer/issue-270

Fix erroneous order-dependent tests in trie code