Fixed registration and added unit tests