Most ideas are tested by an awesome framework. The basic idea is people donate cpu time to test out different versions of stockfish. Truly in the spirit of open source!
http://tests.stockfishchess.org/tests
As for "magic numbers", parameters are done by automated tuning.
Disclaimer: I'm not an expert at this.
There are too many parameters to attempt to optimize everything globally, so it looks like only certain variables are selected (this probably requires lots of domain knowledge) and optimized at a time using something that resembles a gradient descent of sorts. You can read more about it here:
https://chessprogramming.wikispaces.com/Stockfish%27s+Tuning...
There are also other tuning methods. notably, the one used by another chess engine, Texel. Which is also interesting and used by several strong engines. The chess programming wiki is a really good resource if you want to read more.
Finally,I can't find it, but I've read that Stockfish is so strong, that Andscacs, another strong chess engine that participates in the TCEC, was tuned by minimizing the standard deviation of its evaluation function with that of Stockfish. That sort of blew my mind when I first read it.
Thanks for the links. Their optimization approach isn't particularly sophisticated. Not saying I know how to do better, but wouldn't be surprised if it existed.