Added new tests and updated the library for handling corner case