Small code cleanup and addition of a unit test specs