Updated code style and added unit test