Cleanup and added tests