fix: using stderr for errors
fix: handling of back reference 0
fix: no use of process.exit
add: error handling tests