Updated to handle a default case, along with tests.