Redesign API: merge Block and CostFunction

test