On certain classes of algebras in which centralizers are ideals