Minor refactor and extra tests