modify code style and add test code