Add check_context to AbstractCostFunction and associated tests