Thanks!
I also thought that the collision might occur right before the specific location (i.e. to place lights, etc.) so I tried changing the line 3 of the first source code provided like so
to make the actual hit test a little further, but no real change. I did get a correct result at a very specific location, but I'm not sure why. Since I need to restart the game every time I change a little thing, this debugging is too time consuming for me at the moment.
Having a debugging console (writing commands into the Lua console) would be quite useful