Extract test code to mirror Fortran version.

2 jobs for master in 38 seconds (queued for 1 second)