Small code reformat
Refactor and fix unit test