Apply @andrewsmedina's suggestion and improve tests