Improve unit tests

Code coverage is now 98%.