histfactory: write_measurement improvements