Turned unsmear into a function. Added tests for it too.