functions library & tests