Disable destroy links

Fixes bug #1368592: disabled links were still working due to events being attached to click instead of listening for the fired event.

The machine token creation and rendering code has also been refactored to remove duplication and allow the event attaching code to only be added once.
We should also have some tests to make sure these handlers are added.