Fixed some of the failing unit tests after moving code around - a few more still to fix