Updated example

Added scoping test, moved tests into functions