Refactoring

A refactoring of the analysis tests and plotting.