CE-1018 Fix fatal errors and unit tests