Fix attachment ordering with negative values

Also move `uniquify_ordering` functionality to `Attachable` and rewrite it to improve clarity.

Fixes https://www.pivotaltracker.com/story/show/61203896