fix unittest for scopes and add scope tests