Fix erroneous order-dependent tests in trie code

Fixes #270. See #362 (awaiting confirmation that this fix is correct).