Issue 771 followup

This refactors the solution from #771 to be a bit simpler and also pulls in the fixed spec from #746 (originally reported in #745).

/cc @JonRowe