Unit Test

Add unit tests and full (or close to full) coverage