Adaptive mesh refinement for numerical simulation of MHD instabilities in tokamaks: JOREK code