Added a lot of functional tests