Added some testing and plotting functions