We present a new algorithm for fitting and classifying polarized radio sources, which is based on the QU fitting method introduced by OSullivan et al. and on our analysis of pulsars. Then we test this algorithm using Monte Carlo simulations of observations in the 16 cm band of the Australia Telescope Compact Array (1.3-3.1 GHz), to quantify how often the algorithm identifies the correct source model, how certain it is of this identification, and how the parameters of the injected and fitted models compare. In our analysis we consider the Akaike and Bayesian Information Criteria, and model averaging. For the observing setup we simulated, the Bayesian Information Criterion, without model averaging, is the best way for identifying the correct model and for estimating its parameters. Sources can only be identified correctly if their parameters lie inside a Goldilocks region: strong depolarization makes it impossible to detect sources that emit over a wide range in RM, whereas sources that emit over a narrow range in RM cannot be told apart from simpler sources or sources that emit at only one RM. We identify when emission at similar RMs is resolved, and quantify this in a way similar to the Rayleigh criterion in optics. Also, we identify pitfalls in RM synthesis that are avoided by QU fitting. Finally, we show how channel weights can be tweaked to produce apodized RM spectra, that observing time requirements in RM synthesis and QU fitting are the same, and we analyse when to stop RMClean.