Completed historybufferadd function, added new tests