Did you take a blood test for magnesium level?

Blood tests are pretty useless for magnesium. The deficiency is in cells, magnesium level in blood is not a good test for that deficiency.

They have blood tests for both (serum or RBC):

The Magnesium RBC Test measures magnesium inside red blood cells, providing a more accurate assessment of magnesium status than serum tests.

wouldn't a cell deficiency lead to it depleting also the magnesium levels in the blood, simply based on osmosis?

The organism dumps Mg on the blood as much as necessary because it needs to remain in stable concentrations.

When a serum Mg test comes out low, the patient already has severe deficiency and visible symptoms, so isn’t very useful unless you’re investigating a systemic issue.

As explained by my endocrinologist.

If blood concentrations drop, you die.

what is a good test for magnesium deficiency?

They only have blood tests, and that's not very useful.