fixed private context creation code and tests