fixing ps7 divergence code and adding basic tests