fixes and some new tests