Improved error checking and exception refactor.
Add test for #20 (now seems fixed with last refactor)
Fixed wrong behavior on put_attachment method (Fix #19)