Major testing overhaul to make tests as idempotent as possible. Version bump to 1.0.4.