Fix default_scope bug, simplier code and better testing