Reorganize tests into unit and functional tests