improved avl, main testing code