staring to add tests and fixing some bugs but didn't want to do too much to the actual code yet
Merge pull request #1 from doowb/rework

starting to add tests and fixing some bugs but didn't want to do too much...