Fix error assertions. Refactoring of ContractConverter