improve costsens and add tests