Make checkout code more testable

We create a constructor function, rather than use a singleton object. See
http://www.adequatelygood.com/Writing-Testable-JavaScript.html for my justification for
doing this.