Some improvements on unit tests (still need more fixes)