Fixed bug with canonicalPfx function (Thx Andy)
Added test cases to show it works.