[Fix #397] Fix eval interruption binding

Also extracted some common util code into a separate file.