Fixed the issue for #312,#305 and #308

About #312,#305, I don't know if the fix is the best. But almost all tests work fine, except 'CommentsInVariableRuleAccepted' which allow add comment any place. I think it is no problem for us.