Add specs 

Merge in the branch that has specs added.

Also includes many refactorings/improvements based on adding test coverage.