Unit test bugfixes

Signed-off-by: Michael Greenhill <doctorjbeam@gmail.com>