Adds unittests and fixes bugs

Long term memory functions dramatically different now, and requires
documentation