continued cleaning up code and hardening tests