improve error handling, optionally allow padding, improve test cases
check key order in dictionaries