Added tests and logic to verify the correct path