add Error, refactored undefined to value literal
update examples
add generic type declarations
remove redundant exmaples
added error test