Take into account remarks after xavier's code  review
Add many tests to test getLocale algorithm.