Safer merge with tests