Refactore checkRoute method and add test cases