Synthesis of amides and thioesteres derivatives, precursors to heterocyclic thiazolidinones