more fixes and tests