Module refactor and extra tests