(maint) Add various unit tests.

Adding many more tests to cover previous implementations.