Core Unit Test

With changes to support unit testing.