Adding debug statements closer to open_port
Use ct_run if available; fixes strange issues with getting erl/ct to stop