Fixed package restoration and refactored tests a little