The demographics of the STEM fields are very different from the general population. Is there an objective test which can determine whether the difference is at least partially due to discrimination?

Sure, one can consider other examples. I think the question is more important to understand in cases where the gap is bigger. In some areas of STEM we are not talking about just 10% difference, but way higher numbers (see for example here). It would also be interesting to figure out why some other areas have so few male students.

The main influence for choice of major are (in this order) student themselves, parent, HS teacher.
Shockingly career earnings/goals aren't a factor.
http://stepup.education.illinois.edu/sites/default/files/GenerationMe.pdf

Think about what it means to be biased. What it means for a selection process to be biased against applicants of type x is that it's harder for them to make it through. Which means applicants of type x have to be better to get selected than applicants not of type x. [1] Which means applicants of type x who do make it through the selection process will outperform other successful applicants. And if the performance of all the successful applicants is measured, you'll know if they do.

Of course, the test you use to measure performance must be a valid one. And in particular it must not be invalidated by the bias you're trying to measure. But there are some domains where performance can be measured, and in those detecting bias is straightforward. Want to know if the selection process was biased against some type of applicant? Check whether they outperform the others. This is not just a heuristic for detecting bias. It's what bias means.

The problem is that there seem to be no such tests. The performance of academics is typically evaluated by very subjective parameters, such as citation indexes.

You could run into problems because of different distributions. If group A and B both have a mean score of zero, but A has a standard deviation of one and B has a standard deviation of two, and you filter out everyone with a negative score, then the people in group B that pass score twice as high as the people in group A, even though there was no bias.

Based on your previous votes, our recommender system estimates the probability that you will find this post
interesting. The estimates become more accurate as you rate more posts.