Fixed a bug in context incapsulation