Cleaned up history.py and started some unit tests