add basic error handling and trivial tests