Fix flow backup for first run, add tests