Add unload template logic into control flow with tests