Move utility method to util class from test
Better exception message
improve docs