Rewrote test loop to remove copy/paste code.