[test] Refactor initialization to make it more reusable

beat/beat.cmdline re-implements similar parts so
make them reusable
4 jobs for 103_algorithm_database_sharing in 25 minutes and 14 seconds (queued for 7 seconds)
Status Job ID Name Coverage
  Build
passed #216328
docker-build
build_linux_36

00:17:16

64.0%
passed #216329
docker-build
build_linux_37

00:17:05

64.0%
passed #216326
macosx
build_macosx_36

00:19:55

64.0%
passed #216327
macosx
build_macosx_37

00:19:50

64.0%