test improvements and refactoring -- not done yet, but stopping point.