Fixed a Bug in the Ray algorithm.

Added more testcases in the ray.
Merge branch 'develop'