fix crashes in core test, refine flags usage