Major surgery to make the portable library much more testable