majoy refactoring, new unit test, plot_pkls.py script