add a few tests, and start refactoring to make simplier