Some fixes & create functional tests