Add several tests, corrected major implementation errors in
VariableManager