[TIMOB-12354] Fixed setting the context on delayed functions
[TIMOB-12354] Fixed some bugs with detecting non-local values