Refactor and add specs and spec helper.