Fix implementation bug and better error handling for both ouicards.js and our example