rewrite and reorganize tests, add tests for error throwing