several fixes and according tests