Fixed some issues; more unit tests