Add tests, rework some history stuff