Fixes to function that computes unit_cost