Remove logging, improve error handling and tests