test: Ensure deferred functions get called in main()

Signed-off-by: Lewis Marshall <lewis@lmars.net>
Merge pull request #134 from flynn/run-deferred-calls-at-exit

test: Ensure deferred functions get called in main()