fix bug; add test