fix doTasks: should save state before redirecting, because the alarm may fire pretty late and bg page reloaded