Test and implementation of #calculate_roots