Cost function test.