Fixes `sed -i` on OS X.

Using `sed -i.bak` instead of `sed -i` which works for both BSD an GNU
versions of OS X.

`make test` now passes on both OS X and GNU/Linux.
Fixes #5.
Add a trap to prevent leaking *.bak