Add more tests cases and fix the reverse scan problem