Use sinon instead of hand-rolled code for tests