change the comparator logic and ge the table name for stream once instead of querying everytime and fix tests cases