Fixed some error not detected from unit tests