bemhtml: re-entrant BEMContext

backport of https://github.com/bem/bem-bl-xjst/pull/8/