Fix bug in compare logic
Add substr test