fix pre-launch bug (fix #1772)

and add tests