Error handling and a couple of basic tests