[#1390] Move context definition to prevent exception