Add comments and unit tests