modified and add unit test