[Core] Added unit tests

Added unit test for bug 17316 - Monodevelop overwrites conditional references
Also simplified a bit the fix.