Adding regression tests. Error handling almost back.