Add comments and its tests. Some bugs are there