Improved test
Better error handling