Error handling and a couple of tests