Cleanup and adding tests