Bug fixes, Unit tests