Update unit tests + fix 2 minor bugs