use correct context when copying template which has just been modified (IDEADEV-40881)