Improved feedback control of MHD instabilities and errors fields in reversed-field pinch and tokamak