Moves test functions to lib/test