Fix tests

A retake on fixing #52, #66, and various clean ups. Without dealing with seeding stochastic tests (#48).