test: Ensure deferred functions get called in main()