Finally fixed, tests ok