Add comments and update unit tests