Fix porfolio assignment and write more tests