Several bug fixes
update test