Add destructor, refactor tests