Fix ray-intersection code and test