Cleaning up profile module and adding some tests