Fixed and added unit test