Guard against bad cost function
A test for locked version cost function