fix error types
move tests around, relax error types
more refactoring