Minima unit tests + bug fixes