fix bug, implement test