Code cleanup. Adding more tests.
6 files changed