[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)