Improved unit tests, fixed bugs found in unit testing

Signed-off-by: goneall <gary@sourceauditor.com>