So, I have found the answer to my problem.
If you look at the source code for the cvFitEllipse2 function that you can find in ...\modules\imgproc\src file: "shapedescr.cpp", you will see that there are two different algorithms for doing ellipse fitting. By default only one is used in the openCV231 version I'm using.
icvFitEllipse_F is the function that caused my problem, but there is also a part of the algorithm that is not used because the following statement is in the code of the cvFitEllipse2 function:
#if 1
icvFitEllipse_F( ptseq, &box );
#else
/*
* New fitellipse algorithm, contributed by Dr. Daniel Weiss
*/
so the new fitellipse algorithm is not compiled.
By changing #if 1 to #if 0 the other algorithm is compiled and used instead of icvFitEllipse_F and everything works fine now.