More tests, error handling tweaks