Test cases, Error handling added and bug fixes