also fix misidentification of scope in function declarations

because code like below does not create a global "a" or "b" variables:

do
	local a = {}
	function a.b()
		-- ...
	end
end

will need to update testcases too.
update functions testcases broken by previous commit