The formula and its application are basically correct: the length of the Equator is 2 * pi * R and equating that with 707 pixels tells us the scale of the map at the Equator. However, any formula involving trigonometric functions of angles that involves pi expects the angles to be given in radians. Therefore, the Mercator position of latitude 51 degrees must be computed as
707 / (2 * pi) * ln(tan(pi / 4 Radians + 51 / 2 Degrees))
= 707 / (2 * pi) * ln(tan(pi / 4 + (51/2) * pi / 180))
= 707 / (2 * pi) * ln(tan(1.23046))
= 116.8
pixels above the Equator.
If degrees are treated as if they were radians, then pi/4 + 51/2 radians is the same as 42.0848 degrees (plus four whole circles--8*360--which makes no difference), which indeed places the location in Spain rather than Belgium. In this case it seems like a relatively small error of just 117 - 91 = 26 pixels has occurred, which can be misleading, because at other latitudes the result would be incredibly far off or undefined. For instance, using 52 instead of 51 in the formula gives a negative tangent whose logarithm is undefined. Increasing to 54.977871437821385 places you 3786 pixels below the Equator!