I have no idea what code you're testing so, as a standalone example of a button that can be dragged and saved.
Lua Code:
local btn = CreateFrame("Button", "Hubb777MovingButton", UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:SetScript("OnClick", function(self, button, ...) print("I've been clicked!") end)
btn:SetMovable(true)
btn:RegisterForDrag('LeftButton')
btn:SetUserPlaced(true) -- Only works if the frame is created before the PLAYER_LOGIN event
btn:SetScript('OnDragStart', btn.StartMoving)
btn:SetScript('OnDragStop', btn.StopMovingOrSizing)
btn:RegisterForClicks("AnyUp")
You will have to move the pieces into your addon. Possibly just the btn:SetUserPlaced(true) and giving the button a name.