Refactored Account History

Also added a bunch of tests and fixed stuff the tests revealed
as broken.