Cleaned up version checking, added unit tests.