make code style changes and add unit tests