Better error handling
Some test updates for better coverage