reworked extend, as_var, and implemented tests