some error handling, and more elaborate tests...