Recent experiments have reached detection efficiencies sufficient to close the detection loophole, testing the Clauser-Horne (CH) version of Bells inequality. For a similar future experiment to be completely loophole-free, it will be important to have discrete experimental trials with randomized measurement settings for each trial, and the statistical analysis should not overlook the possibility of a local state varying over time with possible dependence on earlier trials (the memory loophole). In this paper, a mathematical model for such a CH experiment is presented, and a method for statistical analysis that is robust to memory effects is introduced. Additionally, a new method for calculating exact p-values for martingale-based statistics is described; previously, only non-sharp upper bounds derived from the Azuma-Hoeffding inequality have been available for such statistics. This improvement decreases the required number of experimental trials to demonstrate non-locality. The statistical techniques are applied to the data of recent experiments and found to perform well.