Make tests pass

I updated the code so that the tests now pass on my machine.  I was in a bit over my head so this should be carefully reviewed.