move local_* functions to top of file to fix test compilation