Added tests for secondary sort
Ported to 0.4-rc1