some refactoring, adding of additional tests, and firming up with respect to solution