fixing and adding functional tests