A bit of a refactor and a few more test