fix error and add test