We have figured that the mentioned functions return a wrong Z value when you get the position of a remote unit. It works well if the unit is on the ground / water or in a vehicle, e.g. a chopper. However, it returns the same ground Z value if the unit is inside a building in a second floor or higher.
This only applies to remote units. It works perfect for the local player unit.