Refactor tests slightly, improve error messages