cover legacy history adding with tests. fix some issues