Add unit tests and abstract the Java console

Add JUnit unit tests for Key and User domain objects and abstract the
Java console to remove direct dependency on the console.