refactored main module to be more flexible, added more tests
removing cruft