Heterocyclic corrosion inhibitors for alkaline environments