Moving functions.bash to tools/lib

Change-Id: Id3a43ddad15f61d989d4c9a8a87ea20a2ee34ef5