Tests fixed. Algo fixed