fixed several bugs with the unit testing and a 'one-off' error in the share balance calculations