throw err instead of process.exit

Also some minor clean up of log output during tests.
add tests for how API_SECRET affects the process