a lot of fixes for functionality test