Added test
Better exception description; renaming some functions