some fixes, add test