Add more specs

Also refactor and clean up things on the way. This is work in progress, but I'm
creating the pull request so I can track the coverage using coveralls.