several fixes and new unit ai testing