extracted several helper functions;
added redefine validation error;
test cleanup to avoid validation errors;
made the helper functions private (only define and undefine are public)
Merge pull request #15 from jonsquared/feature/cleanup

Feature/cleanup