Are your metformin pills slow
release? If they are, still seeing the pills present can be normal.
However, if you are having severe diarrhea, it could be that your gut is having difficulty absorbing your medication and there is very short transit time, and it is coming out. Once your diarrhea resolves, the problem with malabsorption of the medication should improve.
You may also look at your diet and restricting carbohydrates to help control your blood sugars.