Factor out DiscoverVersion in sysinfo, use in generic_agent_test:test_masterfiles
(cherry picked from commit d1d45308a518efd5f12a00fa7348d707856da667)