Cleanup and adding some tests