Molecular envelopes around carbon stars. Interferometric observations and models of HCN and CN emission