cleaned up code a little, removed duplicate code, wrapped new methods in tests. All tests pass.